package com.training.java.redbox.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.training.java.redbox.domain.DAOException;
import com.training.java.redbox.domain.Movie;
import com.training.java.redbox.domain.MovieDAO;

@Service
public class MovieServiceImpl implements MovieService {

	@Autowired
	private MovieDAO dao;

	@Override
	public Movie findByPrimaryKey(long id) throws ServiceException {

		try {

			return dao.findByPrimaryKey(id);

		} catch (DAOException e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}

	@Override
	public List<Movie> getAllMovies() throws ServiceException {
		
		try {

			return dao.getAllMovies();

		} catch (DAOException e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}

}
